from django_redis import get_redis_connection

class MyRedis:
    def __init__(self):
        self.coon = get_redis_connection("default")
        # 存储一个字符串
    def setstr(self, key, value):
        self.coon.set(key, value)
        # 设置一个过期时间的参数
    def setex(self, key, value,ex):
        self.coon.setex(key,ex,value)
        # 获取到一个字符串
    def getstr(self, key):
        val =self.coon.get(key)
        if val:
            return val.decode('utf-8')
        else:
            return None
redistoll = MyRedis()